<extend name="Public/base"/>

<block name="body">
	<div class="main-title">
		<h2>拼团订单列表</h2>
	</div>

	<div class="cf">
		<present name="Think.get.hid">
			<a class="btn" href="{$Think.get.refer|base64_decode}">返 回</a>
		</present>
		<!-- <div >查看</div> -->
		<a class="btn" href="__URL__/order">全部</a>
		<a class="btn" href="{:U('order',array('status'=>2))}">拼团中</a>
		<a class="btn" href="{:U('order',array('status'=>3))}">拼团成功</a>
		<a class="btn" href="{:U('order',array('status'=>4))}">拼团失败</a>
		<button class="btn" target-form="ids" onclick="javascript:exportexl();">导出Excel</button>
		
	</div>
	<div class="cf" style="margin-top:10px;">
		<!-- 高级搜索 -->
		<div class="search-form cf">
			<div class="btn-group-click adv-sch-pannel fl">
               	<div class="row">
               		<label>下单时间：</label>
               		<input type="text" id="time_start" name="time_start" class="text input-2x" value="{:I('time_start')}" placeholder="起始时间" /> -
               		<input type="text" id="time_end" name="time_end" class="text input-2x" value="{:I('time_end')}" placeholder="结束时间" />
               	</div>
            </div>
			<div class="sleft">
				<input type="text" name="title"  class="search-input" value="{:I('title')}" placeholder="请输入订单号">
				<a class="sch-btn" href="javascript:;" id="search" url="{:U('Spell/order')}"><i class="btn-search"></i></a>
			</div>

		</div>
	</div>

	<div class="data-table table-striped">
		<table>
			<thead>
				<tr>
					<th class="row-selected">
						<input class="checkbox check-all" type="checkbox">
					</th>
					<th>ID</th>
					<th>订单号</th>
					<th>参团用户</th>
					<th>拼团团长</th>
					<th>拼团名称</th>
					<th>参团时间</th>
                    <th>订单状态</th>
                    <th>拼团状态</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
				<notempty name="info">
				<volist name="info" id="item">
					<tr>
						<td><input class="ids row-selected" type="checkbox" name="" id="" value="{$item['id']}"> </td>
						<td>{$item.id}</td>
						<td><a href="__URL__/views/id/{$item.id}">{$item.sn}</a></td>
						<td><a href="{:U('Member/edit',array('id'=>$item['user_id']))}"><if condition="$item['user']['name'] neq ''">{$item.user.name}<else/>{$item.user.login_user}</if></a></td>
						<td><a href="{:U('Member/edit',array('id'=>$item['teamuserid']))}">{$item.teamuser}</a></td>
						<td><a href="{:U('Spell/info',array('id'=>$item['spell_id']))}">{$item.title}</a></td>
                        <td>{:date('Y-m-d H:i:s',$item['addtime'])}</td>
                        <td>{$statusarr[$item['status']]}</td>
                        <td>{$statearr[$item['teamstatus']]}</td>
                        
						<td>
	<!-- 					<if condition="$item.status eq 2">
							<a class="confirm ajax-get" href='__URL__/upstatus&id={$item.id}&status=3'>完成</a>
						</if> -->
						<if condition="$item.status eq 0">
							<a class="confirm ajax-get" href='__URL__/upstatus&id={$item.id}&status=4'>取消</a>
						</if>
							<a title="详情" href="__URL__/views/id/{$item.id}">详情</a>
						<if condition="$item.status eq 0 or $item.status eq 3">
							<a class="confirm ajax-get" title="删除" href="__URL__/del/id/{$item.id}">删除</a>
						</if>
						</td>
					</tr>
				</volist>
				<else/>
				<td colspan="9" class="text-center"> aOh! 暂时还没有订单! </td>
				</notempty>
			</tbody>
		</table>
	</div>
		<div class="page">
        {$page}
		</div>
</block>

<block name="script">
<link href="__STATIC__/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
<php>if(C('COLOR_STYLE')=='blue_color') echo '<link href="__STATIC__/datetimepicker/css/datetimepicker_blue.css" rel="stylesheet" type="text/css">';</php>
<link href="__STATIC__/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
<script type="text/javascript">
//导航高亮
	highlight_subnav("{:U('Spell/order')}");
    $(function() {
    	$("#search").click(function(){
    		var url = $(this).attr('url');
            var query  = $('.search-form').find('input').serialize();
            query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
            query = query.replace(/^&/g,'');
            if( url.indexOf('?')>0 ){
                url += '&' + query;
            }else{
                url += '?' + query;
            }
    		window.location.href = url;
    	});
    	/*$("#search").click(function(){
       		var $id =$("#order_id").val();
       		if($id!=""){
       			var url ='__URL__/order/id/'+$id;
       		}
			window.location.href = url;
		});*/
    	
        $('#time_start').datetimepicker({
            format: 'yyyy-mm-dd',
            language:"zh-CN",
    	    minView:2,
    	    autoclose:true
        });

        $('#time_end').datetimepicker({
            format: 'yyyy-mm-dd',
            language:"zh-CN",
    	    minView:2,
    	    autoclose:true
        });
    });

    function exportexl(){
    	var ids = "";
    	$(".ids").each(function(i,e){
    		if($(this).is(":checked")){
    			ids += $(this).val()+",";
    		}
    	});
    	var url = "{$excel_url}";
    	if(ids!="") url+="&ids="+ids;
    	location.href = url;
    }
</script>
</block>